#pragma once
#include "qlist.h"
#include "qpoint.h"
/*
 * class Node
**/
class Node {
private : 
	QPointF pos;
	int		degree;
	QString description;
public:
	Node(): pos(0.0, 0.0), degree(0) {};
	Node(double x, double y): pos(x, y) {};
	~Node(void) {};
	QPointF	coord()				{return pos;};
	float	x()					{return pos.x();};
	float	y()					{return pos.y();};
	void	setX(double x)		{pos.setX(x);};
	void	setY(double y)		{pos.setY(y);};
	void	setCoord(QPointF p)	{pos = p;};
	void	increment(void)		{degree++;};
	int		getDegree(void)		{return degree;};
	QString	info()				{return description;};
	void	setInfo(QString s)	{description = s;};
};

/*
 * class Edge
**/
class Edge {
private:
	QList<Node*> nodeList;

public:
	Edge() {};
	Edge(QList<Node*> nodes) {
		nodeList << nodes;
	};

	Edge(Node* n1, Node* n2) {
		nodeList << n1;
		nodeList << n2;
	};

	~Edge(void){};
	QList<Node*>	Edge::nodes() {return nodeList;};
	void			addNode(Node* n) {nodeList << n;};
	Node*			getFirstNode() {return nodeList.first();};
	Node*			getLastNode() {return nodeList.last();};
};

/*
 * class Graph
**/
class Graph {
public:
	Graph(void) {};
	~Graph(void) {
		/*qDeleteAll(edges.begin(), edges.end());
		edges.clear();

		qDeleteAll(nodes.begin(), nodes.end());
		nodes.clear();*/
	};
	
	QList<Node*>	getNodes()			{return nodes;};
	QList<Edge*>	getEdges()			{return edges;};
	void			addNode(Node* n)	{nodes<<n;};
	void			addEdge(Edge* e)	{edges<<e;};
private: 
	QList<Node*>	nodes;
	QList<Edge*>	edges;
};